package recite.word.client.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import recite.word.client.dto.plan.PlanImportWordDTO;
import recite.word.client.dto.plan.PlanSetPlanDTO;
import recite.word.client.service.IPlanService;
import recite.word.client.vo.plan.DayCompleteVO;
import recite.word.client.vo.plan.PlanGetNowVO;
import recite.word.service.base.common.request.BaseRequest;
import recite.word.service.base.common.response.ResponseResult;

/**
 * @program: recite-word-back
 * @description:
 * @author: Mr.lin
 * @create: 2023-01-27 12:30
 **/
@RestController
@RequestMapping("/client/plan")
@Api(tags = "客户端【完成计划】Controller")
public class PlanController {
	@Autowired
	private IPlanService planService;
	
	@PostMapping("/getNow")
	@ApiOperation("获取当前用户计划")
	public ResponseResult<PlanGetNowVO> getNow(){
		PlanGetNowVO ans = planService.getNow();
		return ResponseResult.success(ans);
	}
	
	@PostMapping("/setPlan")
	@ApiOperation("设置计划")
	public ResponseResult setPlan(@RequestBody BaseRequest<PlanSetPlanDTO> dto){
		planService.setPlan(dto);
		return ResponseResult.success("设置计划成功");
	}

	@PostMapping("/havePlan")
	@ApiOperation("查询是否有计划")
	public ResponseResult<Boolean> havePlan() {
		Boolean ans = planService.havePlan();
		return ResponseResult.success(ans);
	}

	@PostMapping("/importWord")
	@ApiOperation("导入新书单词")
	public ResponseResult importWord(@RequestBody BaseRequest<PlanImportWordDTO> dto){
		planService.importWord(dto);
		return ResponseResult.success();
	}

	@PostMapping("/setDayComplete")
	@ApiOperation(("设置今日计划完成并返回数据"))
	public ResponseResult<DayCompleteVO> setDayComplete(){
		DayCompleteVO ans = planService.setDayComplete();
		return ResponseResult.success(ans);
	}
}
